﻿using System;
using System.Collections.Generic;

class SortingAnArray
{
    static void Main()
    {
        Console.WriteLine("Enter the number of elements:");
        int arrayLength = int.Parse(Console.ReadLine());
        int[] arrayOfInts = new int[arrayLength];
        for (int index = 0; index < arrayLength; index++)
        {
            Console.WriteLine("Enter element {0}", index);
            arrayOfInts[index] = int.Parse(Console.ReadLine());
        }
        for (int i = 0; i < arrayLength-1; i++)
        {
            int minValue = arrayOfInts[i];
            int value = i;
            for (int j = i + 1; j < arrayLength; j++)
            {
                if (arrayOfInts[j] < minValue)
                {
                    minValue = arrayOfInts[j];
                    value = j;
                }
                
            }
            int temp = arrayOfInts[i];
            arrayOfInts[i] = arrayOfInts[value];
            arrayOfInts[value] = temp;

        }
        Console.WriteLine("The sorted array is:");
        for (int index = 0; index < arrayLength; index++)
        {
          
            Console.WriteLine(arrayOfInts[index]);
        }
    }
}

